package com.telsoft.hms.lib.admin.data;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

//import org.apache.commons.dbutils.DbUtils;

public class DataPreprocessor {
	public Connection mConnection = null;
	// public Connection mAMConnection = null;
	public PreparedStatement mStmt = null;
	public ResultSet mRs = null;
	// private DataLogger log = null;
	public String mstrLogID;

	public Connection getConnection() throws Exception {
		return mConnection;
	}

	public DataPreprocessor() {
	}

	public void open() throws Exception {
		// detail here 
	}

	public void close() throws SQLException {
		// DbUtils.closeQuietly(mConnection);
		if (mConnection != null) {
			mConnection.close();
		}
		// DbUtils.closeQuietly(mAMConnection);
	}

	public void close(ResultSet rs, PreparedStatement stmt) throws SQLException {
		close(rs);
		close(stmt);
	}

	public void close(PreparedStatement stmt, Connection connection)
			throws SQLException {
		close(stmt);
		close();
	}

	public void close(Connection connection) throws SQLException {
		// DbUtils.closeQuietly(connection);
		if (connection != null) {
			connection.close();
		}
	}

	public void close(PreparedStatement stmt) throws SQLException {
		// DbUtils.closeQuietly(stmt);
		if (stmt != null) {
			stmt.close();
		}
	}

	public void close(Statement stmt) throws SQLException {
		// DbUtils.closeQuietly(stmt);
		if (stmt != null) {
			stmt.close();
		}
	}

	public void close(ResultSet rs) throws SQLException {
		// DbUtils.closeQuietly(rs);
		if (rs != null) {
			rs.close();
		}
	}

	public void close(Connection connection, PreparedStatement stmt,
			ResultSet rs) throws SQLException {
		close(rs);
		close(stmt);
		close();
	}

	// //////////////////////////////////////////////////////

	// private void initAMConnection() {
	// try {
	// if (mAMConnection == null || mAMConnection.isClosed()) {
	// mAMConnection = ConnectionFactory
	// .getConnection(ConnectionFactory.GroupType.ADMIN);
	// }
	//
	// } catch (Exception ex) {
	// SystemLogger.getLogger().error(ex);
	// }
	// }

	// //////////////////////////////////////////////////////

	// private DataLogger getLog() throws Exception {
	// initAMConnection();
	// if (log == null) {
	// log = new DataLogger(mAMConnection);
	// }
	// return log;
	// }

	// //////////////////////////////////////////////////////

	// public void setLog(DataLogger log) {
	// this.log = log;
	// }

	// //////////////////////////////////////////////////////

	// public List logBeforeUpdate(String strModuleName, String strTableName,
	// String strCondition) throws Exception {
	// getLog();
	// return log.logBeforeUpdate(strTableName, strCondition);
	// }

	// //////////////////////////////////////////////////////

	// public void logBeforeDelete(String strModuleName, String strTableName,
	// String strCondition) throws Exception {
	// getLog();
	// log.logBeforeDelete(mstrLogID, strTableName, strCondition);
	// }

	// //////////////////////////////////////////////////////

	// public void logAfterInsert(String strModuleName, String strTableName,
	// String strCondition) throws Exception {
	// getLog();
	// log.logAfterInsert(strTableName, strCondition);
	// }

	// //////////////////////////////////////////////////////

	// public void logAfterUpdate(String strModuleName, List listChangeID)
	// throws Exception {
	// getLog();
	// log.logAfterUpdate(listChangeID);
	// }

	// //////////////////////////////////////////////////////

	// public List logBeforeUpdate(String strTableName, String strCondition)
	// throws Exception {
	// getLog();
	// return log.logBeforeUpdate(strTableName, strCondition);
	// }

	// //////////////////////////////////////////////////////

	// public void logBeforeDelete(String strTableName, String strCondition)
	// throws Exception {
	// getLog();
	// log.logBeforeDelete(mstrLogID, strTableName, strCondition);
	// }

	// //////////////////////////////////////////////////////

	// public void logAfterInsert(String strTableName, String strCondition)
	// throws Exception {
	// getLog();
	// log.logAfterInsert(strTableName, strCondition);
	// }

	// //////////////////////////////////////////////////////

	// public void logAfterUpdate(List listChange) throws Exception {
	// getLog();
	// log.logAfterUpdate(listChange);
	// }
}
